package com.qipay.baas.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.qipay.baas.model.ActionDoc;

public class ActionDocSqlProvider {

    public String insertSelective(ActionDoc record) {
        BEGIN();
        INSERT_INTO("`action_doc`");
        
        if (record.getTitle() != null) {
            VALUES("title", "#{title,jdbcType=VARCHAR}");
        }
        
        if (record.getIcon() != null) {
            VALUES("icon", "#{icon,jdbcType=VARCHAR}");
        }
        
        if (record.getInfo() != null) {
            VALUES("info", "#{info,jdbcType=VARCHAR}");
        }
        
        if (record.getType() != null) {
            VALUES("`type`", "#{type,jdbcType=TINYINT}");
        }
        
        if (record.getOrderNumber() != null) {
            VALUES("order_number", "#{orderNumber,jdbcType=TINYINT}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(ActionDoc record) {
        BEGIN();
        UPDATE("`action_doc`");
        
        if (record.getTitle() != null) {
            SET("title = #{title,jdbcType=VARCHAR}");
        }
        
        if (record.getIcon() != null) {
            SET("icon = #{icon,jdbcType=VARCHAR}");
        }
        
        if (record.getInfo() != null) {
            SET("info = #{info,jdbcType=VARCHAR}");
        }
        
        if (record.getType() != null) {
            SET("`type` = #{type,jdbcType=TINYINT}");
        }
        
        if (record.getOrderNumber() != null) {
            SET("order_number = #{orderNumber,jdbcType=TINYINT}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        
        return SQL();
    }
}